// pages/main/index/postDetail/resume_editor/resume_editor.js
import { getLessLimitSizeImage } from './compressImg/index';
import { uploadFile } from './uploadAliyun/index';
const app = getApp()
const globalData = getApp().globalData;

Page({

  /**
   * 页面的初始数据
   */
  data: {
    valueT:[18,36], 
    weekType: [
      { key:'freeMon', name: "周一",state: false},
      { key:'freeTue', name: "周二",state: false},
      { key:'freeWed', name: "周三",state: false},
      { key:'freeThur', name: "周四",	state: false},
      { key:'freeFri', name: "周五",state: false},
      { key:'freeSta', name: "周六",state: false},
      { key:'freeSun', name: "周日",	state: false}
    ],
    hours: ["00:00","00:30","01:00","01:30","02:00","02:30","03:00","03:30","04:00","04:30","05:00","05:30",
        "06:00","06:30","07:00","07:30","08:00","08:30","09:00","09:30","10:00","10:30","11:00","11:30",
        "12:00","12:30","13:00","13:30","14:00","14:30","15:00","15:30","16:00","16:30","17:00","17:30",
        "18:00","18:30","19:00","19:30","20:00","20:30","21:00","21:30","22:00","22:30","23:00","23:30"
    ],
    count:6,//最大的上传数量,
    imageSize: 100,//图片控制最大kb数
    windowWidth: 0,//屏幕宽度
    code: 1,//简历完善标识
    seekerInfo:{},//简历详情
    form:{},//用来提交的表单
    selectLists:{
      addressLists:[],//户籍所在地选择集合
      nationList:[],//民族
      educationLists:[
          {name:'小学',value:1},
          {name:'初中',value:2},
          {name:'中专/技校',value:3},
          {name:'高中',value:4},
          {name:'大专',value:5},
          {name:'本科及以上',value:6}
      ],//学历集合 教育程度0:不限 1:小学 2:初中 3:中专/技校 4:高中 5:大专 6:本科及以上
      workExperienceLists:[
          {name:'一年以下',value:1},
          {name:'1-3年',value:2},
          {name:'3-5年',value:3},
          {name:'5-10年',value:4},
          {name:'10年以上',value:5},
      ],//工作年限（1：一年以下 2:1-3年 3:3-5年 4:5-10年 5:10年以上
      expectWorkTypeLists:[
          {name:'全职',value:1},
          {name:'兼职',value:2},
          {name:'全职或兼职都看',value:3},
      ],//期望工作类型1：全职，2：兼职，3：全职或兼职 
    },
    salaryForm:{
      type:3, //3月 2 日 1时
      expectSalaryUpper:null,//最高薪资
      expectSalaryLower:null//最低薪资
    },
    birthday: '',		//出生年月
    //其他数据
    resumeJobId: [], //简历 意愿工作岗位ID
    resumeJobName: [],  //简历 意愿工作岗位name
    resumeUsedJobId: [],  //简历 曾经工作岗位ID
    resumeUsedJobName: [],  //简历 曾经工作岗位名称
    
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    const passMap = JSON.parse(options.param)
    console.log("编辑简历界面入参:"+JSON.stringify(passMap))
    this.data.code = passMap.code?Number(passMap.code):1
    let title = ''
    if (this.data.code == 1) {
      title="基本信息"
    } else if (this.data.code == 2){
      title="求职意向"
    } else if (this.data.code == 3){
      title="详细信息"
    }
    // console.log(this.data.code)
    //设置导航标题
    wx.setNavigationBarTitle({
      title: title,
    })

    //刷新页面
    this.setData({
      code: this.data.code
    })


    //方法数据获取
    this.getSeekerInfo() // 简历详情
    this.getAddressLists()//获取省
    this.getNationList()//获取民族
  },

  /*********自己方法******** */

  // 获取简历信息
  getSeekerInfo(){
    let that = this
    wx.showLoading({
      title: '加载中...',
    })
    app.$http.getSeekerInfo().then(res=>{
      wx.hideLoading({
        success: (res) => {},
      })
      res.photos = res.photos ? res.photos.split(','):[]
      //界面刷新
      this.setData({
        seekerInfo: res,
        birthday: (new Date(res.birthday).getFullYear()) || 0,
      })

      console.log(JSON.stringify(res))

      // 设置回显岗位
      if (res.expectPositions) {
        let expectPositionsIds = []
        let expectPositionsNames = []
        res.expectPositions.forEach((item,index) => {
          expectPositionsIds.push(item.positionId)
          expectPositionsNames.push(item.positionName)
        });

        //全局数据保存
        globalData.resumeJobId = expectPositionsIds//简历 意愿工作岗位ID
        globalData.resumeJobName = expectPositionsNames//简历 意愿工作岗位name

      }    

      if (res.beforePositions) {
        let beforePositionsIds = []
        let beforePositionsNames = []
        res.beforePositions.forEach((item,index) =>{
            beforePositionsIds.push(item.positionId)
            beforePositionsNames.push(item.positionName)
        })

        //全局数据保存
        globalData.resumeUsedJobId = beforePositionsIds//简历 曾经工作岗位ID
        globalData.resumeUsedJobName = beforePositionsNames//简历 曾经工作岗位名称
      }

      console.log('麦迪')
    })
  },

  // 获取省
  getAddressLists(){
    let that = this
    app.$http.getAddressLists().then(res => {
      that.data.selectLists.addressLists = res;
      that.setData({
        selectLists: that.data.selectLists,
      })
      // console.log(that.data.selectLists.addressLists)
    })
  },

  // 获取民族
  getNationList(){
    let that = this
    app.$http.getNationList().then(res => {
      that.data.selectLists.nationList = res;
      that.setData({
        selectLists: that.data.selectLists,
      })
      // console.log(that.data)
    })
  },

  /*********************系统方法 */
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    console.log("onShow"+"监听页面显示")
    // 光光【简历编辑公用页面】
    let that = this
    this.data.windowWidth = wx.getSystemInfoSync().windowWidth
    //全局数据获取
    this.data.resumeJobId = globalData.resumeJobId
    this.data.resumeJobName = globalData.resumeJobName
    this.data.resumeUsedJobId = globalData.resumeUsedJobId
    this.data.resumeUsedJobName = globalData.resumeUsedJobName
    console.log('科比')
    // console.log(globalData.resumeJobId)
    // console.log(globalData.resumeJobName)
    // console.log(globalData.resumeUsedJobId)
    // console.log(globalData.resumeUsedJobName)

    //获取vuex中临时存储的全局数据
    // 期望的岗位
    if (this.data.resumeJobId.length>0) {
      let resumeJobIds = this.data.resumeJobId
      let resumeJobNames = this.data.resumeJobName
      let arr = []
      resumeJobIds.forEach((item,index)=>{
        arr.push({id: item,positionName: resumeJobNames[index]})
      })
      //页面刷新
      this.data.seekerInfo.expectPositions = arr
      console.log('期望工作岗位回调')
      console.log(this.data.seekerInfo.expectPositions)
      this.setData({
        'seekerInfo.expectPositions':this.data.seekerInfo.expectPositions
      })
    }
    // 曾经做过
    if(this.data.resumeUsedJobId.length>0){
      let resumeUsedJobIds = this.data.resumeUsedJobId
      let resumeUsedJobNames = this.data.resumeUsedJobName
      let arr = []
      resumeUsedJobIds.forEach((item,index)=>{
        arr.push({id:item,positionName:resumeUsedJobNames[index]})
      })
      // console.log(arr)
      //页面刷新
      this.data.seekerInfo.beforePositions = arr
      console.log('曾经做过工作岗位回调')
      console.log(this.data.seekerInfo.beforePositions)
      this.setData({
        'seekerInfo.beforePositions':this.data.seekerInfo.beforePositions
      })
    }


  },

  //输入框数据双向绑定
  inputedit(e){
    let dataset = e.currentTarget.dataset;
    let key = dataset.key
    let value = e.detail.value
    this.data.seekerInfo[key] = value
    let updateKyValueInfo = this.data.seekerInfo
    updateKyValueInfo[key] = value // key 可以是任何字符串
    //页面刷新
    this.setData({
      seekerInfo: updateKyValueInfo
    })
    // console.log(key)
    // console.log(value)
    // console.log(updateKyValueInfo)
    // console.log(this.data.seekerInfo)
  },
  //性别选择
  genderChoose(e){
    let dataset = e.currentTarget.dataset;
    console.log(dataset)
    this.data.seekerInfo.gender = dataset.gender
    this.setData({
      "seekerInfo.gender":this.data.seekerInfo.gender
    })
    // console.log(this.data.seekerInfo)
  },

  //选择器
  changeFun(e){
    const {code} = e.currentTarget.dataset;
    const {value} = e.detail;
    console.log(e)
    //出生年份
    if (code === 1) {
      this.data.birthday = value
      this.setData({
        birthday: this.data.birthday
      })
    //出生地址
    } else if (code === 2){
      //数组索引
      const rangeIndex = parseInt(value)
      //数组值
      const rangeObject = this.data.selectLists.addressLists[rangeIndex]
      this.data.seekerInfo.nativePlace = rangeObject.name
      console.log(this.data.seekerInfo.nativePlace)
      this.setData({
        "seekerInfo.nativePlace":this.data.seekerInfo.nativePlace
      })
    //民族
    } else if (code === 3){
      //数组索引
      const rangeIndex = parseInt(value)
      //数组值
      const rangeObject = this.data.selectLists.nationList[rangeIndex]
      this.data.seekerInfo.ethnicity = rangeObject.name
      console.log(this.data.seekerInfo.ethnicity)
      this.setData({
        "seekerInfo.ethnicity":this.data.seekerInfo.ethnicity
      })
    //学历
    } else if (code === 4){
      //数组索引
      const rangeIndex = parseInt(value)
      //数组值
      // const rangeObject = this.data.selectLists.educationLists[rangeIndex+1]
      this.data.seekerInfo.education = rangeIndex+1
      // console.log(value)
      // console.log(this.data.seekerInfo.education)
      this.setData({
        "seekerInfo.education":this.data.seekerInfo.education
      })
    //工作年限
    } else if (code === 5){
      //数组索引
      const rangeIndex = parseInt(value)
      //数组值
      // const rangeObject = this.data.selectLists.workExperienceLists[rangeIndex+1]
      this.data.seekerInfo.workExperience = rangeIndex+1
      // console.log(value)
      // console.log(this.data.seekerInfo.education)
      this.setData({
        "seekerInfo.workExperience":this.data.seekerInfo.workExperience
      })
    //期望工作类型
    } else if (code === 6){
      //数组索引
      console.log(this.data.seekerInfo.expectWorkType)
      const rangeIndex = parseInt(value)
      console.log(rangeIndex)
      //数组值
      // const rangeObject = this.data.selectLists.workExperienceLists[rangeIndex+1]
      this.data.seekerInfo.expectWorkType = rangeIndex+1
      console.log(this.data.seekerInfo.expectWorkType)
      // console.log(this.data.seekerInfo.expectWorkType)
      this.setData({
        "seekerInfo.expectWorkType":this.data.seekerInfo.expectWorkType
      })
    }
  },

  //判断学生
  chooseIfStudent(e){
    let dataset = e.currentTarget.dataset;
    console.log(dataset)
    this.data.seekerInfo.isStudent = dataset.type
    this.setData({
      "seekerInfo.isStudent":this.data.seekerInfo.isStudent
    })
  },
  //判断 是否有健康证
  chooseIfHealth(e){
    let dataset = e.currentTarget.dataset;
    console.log(dataset)
    this.data.seekerInfo.isHaveHealthCertificate = dataset.type
    this.setData({
      "seekerInfo.isHaveHealthCertificate":this.data.seekerInfo.isHaveHealthCertificate
    })
  },

  //求职意向-->选择空闲时间弹窗
  clickFreeTime(){
    let that = this
    this.data.weekType.forEach((item,index)=>{
      if (that.data.seekerInfo[item.key]) {
        that.data.weekType[index].state = true
      } else {
        that.data.weekType[index].state = false
      }
    })
    this.setData({
      "weekType":this.data.weekType
    })
    const popView = this.selectComponent('#freeTime_PopView');
    popView.open()
  },
  //空闲时间item点击
  selectWeekType(e){
    const {index} = e.currentTarget.dataset;
    console.log(index)
    this.data.weekType[index].state = !this.data.weekType[index].state
    console.log(this.data.weekType[index].state)
    this.setData({
      "weekType":this.data.weekType
    })
  },
  //空闲时间点击选择器
  bindChangeT(e){
    const val = e.detail.value
    this.data.valueT[0] = val[0]
    this.data.valueT[1] = val[1]
    this.setData({
      valueT: this.data.valueT
    })
  },
  //空闲时间点击取消
  cancelFunTime(e){
    const popView = this.selectComponent('#freeTime_PopView');
    popView.close(e)
  },
  //空闲时间点击完成
  okFunTime(e){
    let that = this
    this.data.weekType.forEach((item,index)=>{
      if (item.state) {
        this.data.seekerInfo[item.key] = true
      } else {
        this.data.seekerInfo[item.key] = false
      }
    })
    // console.log(this.data.valueT)
    this.data.seekerInfo['freeStartTime'] = this.data.hours[this.data.valueT[0]]
    this.data.seekerInfo['freeEndTime'] = this.data.hours[this.data.valueT[1]]
    //刷新页面
    this.setData({
      seekerInfo:this.data.seekerInfo
    })
    //弹窗关闭
    const popView = this.selectComponent('#freeTime_PopView');
    popView.close(e)
  },

  //期望工作岗位(setJob)、曾经做过(useDJob)
  goSelectItem(e){
    const {type} = e.currentTarget.dataset;
    console.log(type)
    let passMap = {
      from: type
    }
    app.$routes.goTo(getApp().$routes.fyz_Select_Job,passMap);
  },

  // 期望薪资 弹窗点击打开
  getExpectedSalary(e){
    const popView = this.selectComponent('#expect_Salary_PopView');
    if (!this.data.seekerInfo.expectWorkType) {
      wx.showToast({
        title: '请先选择期望工作类型',
      })
      return false
    }

    if (this.data.seekerInfo.expectWorkType != 2) {
      this.data.salaryForm.type = 3
    } else {
      this.data.salaryForm.type = 1
    }

    this.data.salaryForm.type = this.data.seekerInfo.expectSalaryUnit? this.data.seekerInfo.expectSalaryUnit: this.salaryForm.type
    this.data.salaryForm.expectSalaryLower = this.data.seekerInfo.expectSalaryLower?this.data.seekerInfo.expectSalaryLower:null
    this.data.salaryForm.expectSalaryUpper = this.data.seekerInfo.expectSalaryUpper?this.data.seekerInfo.expectSalaryUpper:null
    
    //弹窗打开
    popView.open()
  },

  //期望薪资 点击取消
  cancelFunSalary(e){
    const popView = this.selectComponent('#expect_Salary_PopView');
    popView.close(e)
  },

  //期望薪资点击完成
  okFun(e){
    const popView = this.selectComponent('#expect_Salary_PopView');
    popView.close(e)
    //薪资单位
    this.data.seekerInfo.type = this.data.salaryForm.type
    if (this.data.salaryForm.type === 3) {
      //月
      this.data.seekerInfo.expectSalaryUpper = this.data.salaryForm.expectSalaryUpper
      this.data.seekerInfo.expectSalaryLower = this.data.salaryForm.expectSalaryLower
    } else {
      this.data.seekerInfo.expectSalaryUpper = this.data.salaryForm.expectSalaryUpper
      this.data.seekerInfo.expectSalaryLower = this.data.salaryForm.expectSalaryUpper
    }
    this.setData({
      "seekerInfo.type":this.data.salaryForm.type,
      "seekerInfo.expectSalaryUpper":this.data.seekerInfo.expectSalaryUpper,
      "seekerInfo.expectSalaryLower":this.data.seekerInfo.expectSalaryLower
    })
  },
  //期望薪资单位点击选择
  selectExpectSalaryUnit(e){
    const {type} = e.currentTarget.dataset;
    this.data.salaryForm.type = type;
    //页面刷新
    this.setData({
      salaryForm: this.data.salaryForm
    })
},
  //期望薪资输入框
  salaryInputedit(e){
    let dataset = e.currentTarget.dataset;
    let key = dataset.obj
    let value = e.detail.value
    let dict = this.data.salaryForm;
    dict[key] = value;
    //页面刷新
    this.setData({
      salaryForm: this.data.salaryForm
    })
  },
  //是否有社保
  chooseIfHaveSocialInsurance(e){
    const {type} = e.currentTarget.dataset;
    this.data.seekerInfo.haveSocialInsurance = type
    this.setData({
      "seekerInfo.haveSocialInsurance": this.data.seekerInfo.haveSocialInsurance
    })
  },
  //个人照片删除
  deleteimg(e){
    const {index} = e.currentTarget.dataset
    console.log(index)
    this.data.seekerInfo.photos.splice(index,1)
    //刷新页面
    this.setData({
      "seekerInfo.photos":this.data.seekerInfo.photos
    })
  },
  //个人照片选择
  chooseImg(){
    let that = this
    wx.chooseImage({
      count: that.data.count - that.data.seekerInfo.photos.length, //可以上传多少张
      sizeType: ['original','compressed'],
      sourceType: ['album','camera'],
      success: (res)=>{
        let tempFilePaths = res.tempFilePaths;
        console.log(tempFilePaths.length)
        for (let i = 0; i < tempFilePaths.length;i++){
          let filePath = tempFilePaths[i];
          getLessLimitSizeImage(`pressCanvas_${i}`,filePath,that.data.imageSize,that.data.windowWidth,(path) => {
            wx.showLoading({
              title: '上传中，请稍等~',
              mask: true,
            });
            filePath = path;
            console.log(filePath)
            //上传阿里云
            uploadFile({
                filePath: filePath,
                dir: 'resumephoto'
            }).then(res => {
              wx.hideLoading()
              that.data.seekerInfo.photos.push(res.aliyunFileKey);
              //页面刷新
              that.setData({
                "seekerInfo.photos": that.data.seekerInfo.photos
              })
            })
            .catch(err => { console.log('upload fail', err) })
            .finally(() => {
            })
          })
        }
      },
      fail: ()=>{},
      complete: ()=>{}
    });

  },
  //保存按钮
  saveForm(){
    // wx.showToast({
    //   title: '保存按钮',
    // })
    let obj = this.checkForm()
    console.log(obj)
    if(obj){
      // 不是需要编辑求职意向的的时候 不需要更改新增单位的时候
      if(this.data.code !== 2){
          obj.expectSalaryLower = -1 //跳过薪资区间
          obj.expectSalaryUpper = -1
      }

      // code 为 1 或者 2的时候 要把  曾经做过  和 个人照片 带上 不要被清空 坑
      if(this.data.code == 1 || this.data.code == 2){
          obj.photos = this.data.seekerInfo.photos.toString()
          let arr = []
          if(this.data.seekerInfo.beforePositions && this.data.seekerInfo.beforePositions.length >0 ){
              this.data.seekerInfo.beforePositions.forEach((item,index)=>{
                  arr.push({id:item.id,name:item.positionName})
              })
              obj.beforePositions = arr
          }else{
              obj.beforePositions = arr
          }

      }

      app.$http.saveSeekerInfo(obj).then(res => {
        wx.showToast({
            title: '修改成功',
            icon: 'none'
        })
        setTimeout(()=>{
            wx.navigateBack()
        },1000)
      })
    }
  },
  //空的方法
  emptyFunction(){
    console.log('空的方法打印')
  },

  // 公用表单校验器
  checkForm(){
    let data = this.data.seekerInfo
    console.log(data)
    //基本信息校验
    if(this.data.code == 1){

      console.log('基本信息校验')
      // 基本信息
      if(!data.name || data.name.length < 2 || data.name.length > 40){
        wx.showToast({
          title: '姓名应为2-20个汉字或4-40个字母',
        })
        return false
      }else if(!data.gender){
        wx.showToast({
          title: '请选择性别',
        })
        return false
      }else if(!data.birthday){
        wx.showToast({
          title:'请选择生日年份'
        })
        return false
      }else if(!data.contactNumber || data.contactNumber.length != 11){
        wx.showToast({
          title:'请填写联系电话且必须是11位手机号'
        })
        return false
      }else if(!data.nativePlace){
        wx.showToast({
          title:'请选择户籍所在地'
        })
        return false
      }else if(!data.ethnicity){
        wx.showToast({
          title:'请选择民族'
        })
        return false
      }else if(!data.education){
        wx.showToast({
          title:'请选择学历'
        })
        return false
      }else if(!data.workExperience){
        wx.showToast({
          title:'请选择工作年限'
        })
        return false
      }else if(data.isStudent !== false && data.isStudent !== true){
        wx.showToast({
          title:'请选择身份'
        })
        return false
      }else if(data.isHaveHealthCertificate !== false && data.isHaveHealthCertificate !== true){
        wx.showToast({
          title:'请选择有无健康证'
        })
        return false
      }else{
        // 封装 基本信息的数据集合
        let obj = {
            name:data.name,
            gender:data.gender,
            birthday:data.birthday,
            contactNumber:data.contactNumber,
            nativePlace:data.nativePlace,
            ethnicity:data.ethnicity,
            education:data.education,
            workExperience:data.workExperience,
            isStudent:data.isStudent,
            isHaveHealthCertificate:data.isHaveHealthCertificate
        }
        if(data.height){
            obj.height = data.height
        }
        return obj
      }

    // 求职意向 校验
    }else if(this.data.code == 2){
      // 求职意向
      let obj = {
        name:data.name,
        gender:data.gender,
        birthday:data.birthday,
        contactNumber:data.contactNumber
      }

      data.expectSalaryUpper = data.expectSalaryUpper?Number(data.expectSalaryUpper):false
      data.expectSalaryLower = data.expectSalaryLower?Number(data.expectSalaryLower):false

      // console.log(data.expectSalaryUnit)

      if(!data.expectWorkType){
        wx.showToast({
          icon:'none',title:'请选择期望岗位类型'
        })
        return false
      }else if((data.expectPositions && data.expectPositions.length < 1) || !data.expectPositions){
        wx.showToast({
          icon:'none',title:'请选择期望岗位'
        })
        return false
      }


      // 如果 薪资 都填了的话
      if(data.expectSalaryUpper && data.expectSalaryLower){

        if(!data.expectSalaryUnit){
          wx.showToast({
            icon:'none',title:'薪资单位必选'
          })
          return false
        }

        if(data.expectSalaryUnit == 3){
          if((data.expectSalaryUpper > 30000 || data.expectSalaryUpper < 850) || (data.expectSalaryLower > 30000 || data.expectSalaryLower < 850) || data.expectSalaryLower > data.expectSalaryUpper){
            wx.showToast({
                icon:'none',title:'最低薪资不得小于850，最大薪资不得大于30000'
            })
            return false
          }
        }

          if(data.expectSalaryUnit == 2){
            if(data.expectSalaryUpper < 40 || data.expectSalaryUpper > 3000){
              wx.showToast({
                  icon:'none',title:'薪资必须在40-3000之间'
              })
              return false
            }
          }

          if(data.expectSalaryUnit == 1){
            if(data.expectSalaryUpper < 10 || data.expectSalaryUpper > 100){
              wx.showToast({
                  icon:'none',title:'薪资必须在10-100之间'
              })
              return false
            }
          }

          obj.expectSalaryLower = data.expectSalaryLower
          obj.expectSalaryUpper = data.expectSalaryUpper
      }

      // 计算岗位
      if(data.expectPositions && data.expectPositions.length >0 ){
          let arr = []
          data.expectPositions.forEach((item,index)=>{
              arr.push({id:item.id,name:item.positionName})
          })
          obj.expectPositions = arr
      }
        
      obj.expectSalaryUnit = data.expectSalaryUnit
      obj.expectWorkType = data.expectWorkType

      // 计算 空闲时间 兼职的时候才有空闲时间
      if(data.expectWorkType === 2){

        let num_time = 0
        this.weekType.forEach((item,index)=>{
          if(data[item.key]){
              num_time++;
          }
        })

        if(!num_time){
          wx.showToast({
              icon:'none',title:'空闲时间必选'
          })
          return false
        }else if(!data.freeEndTime || !data.freeStartTime){
          wx.showToast({
              icon:'none',title:'空闲时间开始结束时间必选'
          })
          return false
        }else{
          this.weekType.forEach((item,index)=>{
              if(item.state){
                  obj[item.key] = true
              }
          }) 

          obj.freeEndTime = data.freeEndTime
          obj.freeStartTime = data.freeStartTime
        }

      }

      return obj
   }else if(this.data.code == 3){
      // 详细信息
      let num = 0
      let obj = {
          name:data.name,
          gender:data.gender,
          birthday:data.birthday,
          contactNumber:data.contactNumber
      }
      let arr = []
      if(data.beforePositions && data.beforePositions.length >0 ){
          data.beforePositions.forEach((item,index)=>{
              arr.push({id:item.id,name:item.positionName})
          })
          obj.beforePositions = arr
          num++
      }else{
          obj.beforePositions = arr
      }

      if(data.haveSocialInsurance === false || data.haveSocialInsurance === true ){
          obj.haveSocialInsurance = data.haveSocialInsurance
          num++
      }

      if(data.photos && data.photos.length > 0){
          obj.photos = data.photos.toString();
          num++
      }else{
          obj.photos = ''
      }

      if(num){
          return obj
      }else{
        wx.showToast({
          icon:'none',title:'至少完善一项信息'
        })
        return false
      }  
   }

  }

})